package com.hfh.main.group.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hfh.main.group.entity.GroupDetailEntity;
import com.hfh.main.group.mapper.GroupDetailMapper;
import com.hfh.main.group.service.GroupDetailService;
import com.hfh.main.user.entity.UserEntity;
import com.hfh.main.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class GroupDetailServiceImpl extends ServiceImpl<GroupDetailMapper, GroupDetailEntity> implements GroupDetailService {

    @Autowired
    private GroupDetailMapper groupDetailMapper;

    @Autowired
    private UserService userService;

    @Override
    public String queryLeaderByGroupNo(String param) {
        QueryWrapper<GroupDetailEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(("group_id"), param);
        List<GroupDetailEntity> groupDetailEntities = groupDetailMapper.selectList(wrapper);
        if (CollectionUtil.isNotEmpty(groupDetailEntities)) {
            return groupDetailEntities.get(0).getAcc();
        }
        return "";
    }

}
